/**
 * 立方体类
 * */
package cn.com.ldns.opentetris.shape;

import javax.microedition.khronos.opengles.GL10;

import cn.com.ldns.opentetris.shape.model.Acceleration;
import cn.com.ldns.opentetris.shape.model.Position;

public class Cube extends BaseShape{
	
	private static float vertices[] ={
		 	-0.1f,-0.1f, 0.1f
			, 0.1f,-0.1f, 0.1f
			, 0.1f, 0.1f, 0.1f
			,-0.1f, 0.1f, 0.1f
			//back
			,-0.1f,-0.1f,-0.1f
			, 0.1f,-0.1f,-0.1f
			, 0.1f, 0.1f,-0.1f
			,-0.1f, 0.1f,-0.1f
	};
	
	private static short indices[]={
		0,1,2,0,2,3,
		0,4,7,0,3,7,
		3,7,6,3,2,6,
		4,7,6,4,5,6,
		0,4,5,0,1,5,
		1,2,5,2,5,6
	};
	
	static float[] color = new float[]{
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f,
		1f, 1f, 0f, 0f
    	};
	
	static float[] textureCoords = {
		0,1f,
		1f,1f,
		1f,0,
		0,0
	};

	private Position position = new Position(0, 4, -4);

	public Cube() {
		super(vertices, indices,null);
	}

	public Cube(float[] vertex) {
		super(vertex, null, null);
	}
	
	public Cube(float[] vertex, short[] index) {
		super(vertex, index, null);
	}
	
	public Cube(float[] vertex, float[] color) {
		super(vertex, null, color);
	}
	
	public Cube(float[] vertex, short[] index, float[] color) {
		super(vertex, index, color);
	}
	
	@Override
	public void draw(GL10 gl) {
		super.draw(gl);
		gl.glDrawElements(GL10.GL_TRIANGLES, index.length, GL10.GL_UNSIGNED_SHORT, indexBuff);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		if(textureID != -1 || textureBuff != null)
		{
			gl.glDisable(GL10.GL_TEXTURE_2D);
			gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
		}
	}
}
